<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>现场办公系统-登录</title>
<script src="__PUBLIC__/static/js/fixPNG.js" type="text/javascript"></script>
<!--[if lt IE 7]>       
 <script src="js/fixPNG.js"></script>         
 <script>
 DD_belatedPNG.fix('img,.nav ul li a,.nav ul li a:hover');
 </script>     
<![endif]-->
<link rel="stylesheet" href="__PUBLIC__/static/css/login.css" type="text/css"></link>
<!-- 加载esayUI开始 -->
<script type="text/javascript" src="__PUBLIC__/static/esayUI/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/esayUI/1.3.2/jquery.easyui.min.js"></script>
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="__PUBLIC__/static/esayUI/1.3.2/themes/default/easyui.css"  />
<script type="text/javascript" src="__PUBLIC__/static/esayUI/1.3.2/locale/easyui-lang-zh_CN.js"></script>
<!-- 加载esayUI结束 -->
<script type="text/javascript">
var password;
var username;
var pwdPrompt;
var vcode;

$(function() {
	username = $('#username');
	password = $('#password');
	pwdPrompt = $('#pwdPrompt');
	vcode = $('#vcode');
	
	$('#loginBTN').click(function() {
		loginHandler();
	});
	
	$('#login').keydown(function(event){
		if(event.keyCode==13){
			loginHandler();
		}
	});
	 
	pwdPrompt.focus(function() {
		pwdPrompt.hide();
		password.show().focus();
	});

	password.blur(function() {
		if ($(this).val() == "") {
			pwdPrompt.show();
			password.hide();
		}
	});
});

function loginHandler() {
	var name = username.val();
	var pwd = password.val();
	if (name && name != '您的用户名' && pwd && pwd != '您的密码') {
		 $.post("public/check_verify", {
	        code : vcode.val()
	        }, function(data) {
	        if (data == true) {
	            $.post("user/login", {"username":name, "password":pwd}, function(data) {
					if (data && data.status == 1) {
						$.messager.alert('提示', data.info, 'warning');
						window.location.href = "index.php/admin/index";
					} else {
						$.messager.alert('提示', data.info, 'warning');
						//setTimeout('window.location.href = "/login"', 1000);
					}
				}, "json");
	        } else {
	        	$.messager.alert('提示', '验证码输入错误!', 'warning');
	          	getVcode($('login_code'));
	        }
	    });

		
	}
}

function getVcode(img) {
	 var verifyURL = "admin.php/public/verify/";
	   var time = new Date().getTime();
	   $(img).attr({
	      "src" : verifyURL + "/" + time
	   });
}

</script>
</head>
<body>
<!--top开始-->
<div id="login">
<div class="login">
<div class="login_logo"><img src="__PUBLIC__/static/css/images/login_logo.png" width="630" height="113" /></div>
<div class="clear"></div>
<div class="Box">
<input type="text" id="username" style=" font-size:14px; color:#494949;" class="login_text" value="您的用户名" onfocus="if (value =='您的用户名'){value ='';}" onblur="if (value ==''){value='您的用户名';}"/>
<input type="password" id="password" class="login_passward" style="display:none;font-size:14px; color:#494949;" />
<input type="text" id="pwdPrompt" value="您的密码" class="login_passward" style="font-size:14px; color:#494949;"/>
<label style="float:left; width:325px;color:#333;"></label>
<img src="{:U('/admin.php/public/verify',array())}" class="login_code" onclick="getVcode(this)"/>
<input type="text" id="vcode" style=" font-size:14px; color:#494949;" class="login_vcode" value="请输入验证码" onfocus="if (value =='请输入验证码'){value ='';}" onblur="if (value ==''){value='请输入验证码';}">
<input id="loginBTN" type="button" value=" " class="login_btn" />
</div>
<div class="clear"></div>
<div class="login_foot">
<div class="clear"></div>
</div>
</div> 
</div>
<!--top结束-->

</body>
</html>